package examples.codequality.infrastructure;

import examples.codequality.domain.User;

import java.util.UUID;

/**
 * @author baigod
 */
public class UserConverter {

    public static User toEntity(UserDO userDO) {
        User user = new User();
        user.setId(UUID.fromString(userDO.id()));
        user.setUsername(userDO.username());
        return user;
    }

    public static UserDO toDo(User user) {
        return UserDO.builder()
                .id(user.getId().toString())
                .username(user.getUsername())
                .build();
    }
}